package day20171002;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.IOException;

public class JsoupTripadvisorTest {
    public static void main(String[] args) throws IOException {
        String url = "https://www.tripadvisor.cn/Restaurants";
        String url2 = "https://www.tripadvisor.cn/Restaurants-g297463-c11-Chengdu_Sichuan.html";

        Document doc = Jsoup.connect(url).get();
        Document doc2 = Jsoup.connect(url2).get();

        Elements ul = doc.getElementsByTag("ul");

        Element ul3 = ul.get(3);

        Elements allli = ul3.getElementsByTag("li");

        for (int i = 0;i< allli.size();i++){
            Elements geta = allli.get(i).select("a");
            //System.out.println(geta);
            String text = geta.text();
            String href = geta.attr("href");

            System.out.print(text+"\n"+href+"\n\n");
        }


        Elements iii = doc2.select("div#EATERY_SEARCH_RESULTS");

        System.out.println(iii);



    }
}
